package com.md.client.helper;

import com.fasterxml.jackson.core.type.TypeReference;
import com.md.api.OpenUsersApi;
import com.md.base.BaseClient;
import com.md.model.system.BaseOpenController;
import com.md.model.system.CommonResult;
import com.md.request.open.CheckPermissionRequest;
import com.md.request.open.QuerySimpleUsersRequest;
import com.md.request.open.QueryUsersRequest;
import com.md.request.RegisterUsersRequest;
import com.md.response.UsersResponse;
import com.md.response.open.SimpleUsersResponse;

/**
 * @author 刘骄阳
 * 2024-10-11 15:05
 */
public class DefaultOpenUsersController extends BaseOpenController implements OpenUsersApi {

  public DefaultOpenUsersController(final BaseClient baseClient,
                                    final String endpoint) {
    super(baseClient, endpoint, "user-center", "/apps/users" + PATH_PREFIX);
  }

  @Override
  public CommonResult<UsersResponse> registerUsers(final RegisterUsersRequest request) {
    return null;
  }

  @Override
  public CommonResult<UsersResponse> queryUserInfo(final QueryUsersRequest request) {
    return getBaseClient().post(buildPostUrl("/query"), request,
      new TypeReference<CommonResult<UsersResponse>>() {
      });
  }

  @Override
  public CommonResult<Boolean> checkPermission(final CheckPermissionRequest request) {
    return getBaseClient().post(buildPostUrl("/check-permission"), request,
      new TypeReference<CommonResult<Boolean>>() {
      });
  }

  @Override
  public CommonResult<SimpleUsersResponse> simpleInfo(final QuerySimpleUsersRequest request) {
    return getBaseClient().post(buildPostUrl("/simple-info"), request,
      new TypeReference<CommonResult<SimpleUsersResponse>>() {
      });
  }
}
